<?php
/**
 * Created by PhpStorm.
 * User: Ysll <754060604@qq.com>
 * Date: 2017/9/7
 * Time: 16:25
 */


function testPasswordHash()
{
    $hash = password_hash('123456789', PASSWORD_DEFAULT);
    var_dump($hash);
    var_dump(password_verify('123456789', $hash));
}

function testInsertDB()
{
    $db = require __DIR__ . '/../app/services/DatabaseService.php';

    $title = 'SDSADSAD';
    $category_id = 1;
    $content = 'SADSADSADSAD';
    $userid = 4;
    $stmt = mysqli_prepare($db, "INSERT INTO `topics` (`users_id`, `title`, `topics_category_id`, `description`) VALUES (?, ?, ?, ?)");
    $title = mysqli_real_escape_string($db, $title);
    $content = mysqli_real_escape_string($db, $content);
    if (mysqli_stmt_bind_param($stmt, 'isis', $userid, $title, $category_id, $content) == false) {
        var_dump('error 1');
    }
    if (!mysqli_stmt_execute($stmt)) {
        var_dump('error 2');
    }
    var_dump(mysqli_stmt_insert_id($stmt));
}

//testPreg();

function testPreg() {
    $str = "AbcAdc\r\n";
}

testPath();

function testPath() {
    $str = '../../public/files20170909\9dffb616e5dd37f6ab31860c4871c4a5.jpeg';
    echo dirname($str);
}